/**
 * db
 *
 * @author xiaomi
 */
'use strict';

const knex = require('knex');
const bookshelf = require('bookshelf');

const knexConfig = require('../knexfile')[process.env.NODE_ENV];
const db = bookshelf(knex(knexConfig));
// https://github.com/tgriesser/bookshelf/wiki/Plugin:-Model-Registry
db.plugin('registry');

// https://github.com/tgriesser/bookshelf/wiki/Plugin:-Virtuals
// db.plugin('virtuals');


// db.shim
require('./lib/db.shim')(db);

module.exports = db;
